import { Toast } from 'vant';
let local = {
    get: function (key) {
        // 存储进去的是字符串所以get的也是字符串，因此要转换成对象
        return JSON.parse(localStorage.getItem(key))
    },
    tost(msg){
      return Toast.loading({
        duration: 0,
        message: msg,
        forbidClick: true,
        icon: "like-o",
      });
    },
    
    GetRequest(obj) {
        var urls = location.search; //获取url中"?"符后的字串
        if (urls.indexOf("?") != -1) {
          var str = urls.substr(1);
          if (urls.indexOf("&") != -1) {
            var arr = str.split("&");
            var id = arr[0].split("=")[1];
            var token = arr[1].split("=")[1];
            return (obj = {
              id: id,
              token: token,
            });
          } else {
            var id = str.split("=")[1];
            return (obj = {
              id: id,
            });
          }
        }
      }
}
export default {
    install: function (vm) {
        vm.prototype.$local = local // 最后要输出一下才能使用
    }
}